import Api from "../config/api";
import Config from "../config/common"

export const searchProduct = (data) => {
    return new Promise((resolve, reject) => {

        const handleData = Object.assign({
            categoryId: 69,
            method: "searchProduct.do",
            pageSize: 5
        }, data)

        getApp().sendRequest({
            url: Api.SEARCH_PRODUCT,
            data: handleData,
            method: "POST",
            success(resData){
                if (Config.ERROR_OK == resData.data.code) {
                    resolve(resData.data.data)                
                }else {
                    reject(resData)
                }
            },
            fail(error){
                console.log(error)
            }
        })
    })
}